package com.example.development.java8;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author: vince_zww
 * @date: 2020/8/23 19:41
 * @desceription: List和Map之间装换
 */
public class ListAndMap {
//    List<String> list = new ArrayList<>();
////    Map<String, Object> map = list.stream().collect(Collectors.toMap(list.get(0), Object -> Integer));
//
//    Map<String,>
//    List<IpPool> updateIpPoolList = ipPoolMap.values().stream().collect(Collectors.toList());

//    public static void main(String[] args) {
//        Map<Integer, String> map = new HashMap<>();
//        map.put(10, "apple");
//        map.put(20, "orange");
//        map.put(30, "banana");
//        map.put(40, "watermelon");
//        map.put(50, "dragonfruit");
//        System.out.println("\n1. Export Map Key to List...");
//        List<Integer> result = new ArrayList(map.keySet());
//        result.forEach(System.out::println);
//        System.out.println("\n2. Export Map Value to List...");
//        List<String> result2 = new ArrayList(map.values());
//        result2.forEach(System.out::println);
//    }

    public static void main(String[] args) {
        Map<Integer, String> map = new HashMap<>();
        map.put(10, "apple");
        map.put(20, "orange");
        map.put(30, "banana");
        map.put(40, "watermelon");
        map.put(50, "dragonfruit");
        System.out.println("\n1. Export Map Key to List...");
        List<Integer> result = map.keySet().stream()
                .collect(Collectors.toList());
        result.forEach(System.out::println);
        System.out.println("\n2. Export Map Value to List...");
        List<String> result2 = map.values().stream()
                .collect(Collectors.toList());
        result2.forEach(System.out::println);
        System.out.println("\n3. Export Map Value to List..., say no to banana");
//        List<String> result3 = map.keySet().stream()
        List<String> result3 = map.values().stream()
                .filter(x -> !"banana".equalsIgnoreCase(x))
                .collect(Collectors.toList());
        result3.forEach(System.out::println);
    }



}
